package com.example.demo.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class R {

    private Integer code; // 响应编码
    private String msg; // 提示信息
    private Long count; //分页需要的总条数
    private Object data; // 响应数据

    public static R ok(String msg){
        return R.builder().code(200).msg(msg).build();
    }

    public static R error(String msg){
        return R.builder().code(201).msg(msg).build();
    }

    public static R data(Object data){
        return R.builder().code(200).data(data).build();
    }

    public static R page(Long total,Object data){
        return R.builder().code(0).count(total).data(data).build();
    }

}
